/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.ByteUtil;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.mailbox.MailServiceException;
/*    */ import com.zimbra.cs.service.FileUploadServlet;
/*    */ import com.zimbra.cs.service.FileUploadServlet.Upload;
/*    */ import com.zimbra.cs.zimlet.ZimletException;
/*    */ import com.zimbra.cs.zimlet.ZimletUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.io.IOException;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class ConfigureZimlet
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 41 */     checkRightTODO();
/*    */     
/* 43 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 44 */     Element content = request.getElement("content");
/* 45 */     String attachment = content.getAttribute("aid", null);
/* 46 */     FileUploadServlet.Upload up = FileUploadServlet.fetchUpload(zsc.getAuthtokenAccountId(), attachment, zsc.getAuthToken());
/* 47 */     if (up == null) {
/* 48 */       throw MailServiceException.NO_SUCH_UPLOAD(attachment);
/*    */     }
/*    */     
/* 51 */     Element response = zsc.createElement(AdminConstants.CONFIGURE_ZIMLET_RESPONSE);
/*    */     try {
/* 53 */       byte[] blob = ByteUtil.getContent(up.getInputStream(), 0);
/* 54 */       ZimletUtil.installConfig(new String(blob));
/*    */     } catch (IOException ioe) {
/* 56 */       throw ServiceException.FAILURE("cannot configure", ioe);
/*    */     } catch (ZimletException ze) {
/* 58 */       throw ServiceException.FAILURE("cannot configure", ze);
/*    */     } finally {
/* 60 */       FileUploadServlet.deleteUpload(up);
/*    */     }
/* 62 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 67 */     notes.add("TDB");
/*    */     
/* 69 */     notes.add("Currently the soap gets a uploaded blob containing metadata. The zimlet name is encoded in in the blob and is decoded in ZimletUtil. We need a way to know the zimlet name (and cos name if any, currently it seems to always only update the default cos) in the SOAP handler in order to check right.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/ConfigureZimlet.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */